package com.po;


import com.utils.JDBCUnits;
import com.utils.MD5;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户的基本信息
 */
public class User {
    //用户的名字
    private String name;
    //用户的性别
    private String sex;
    //用户的id
    private int id;
    //用户的等级
    private String grade;
    //用户的账号
    private String username;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public User() {
    }

    public User(String name, String sex, int id) {
        this.name = name;
        this.sex = sex;
        this.id = id;
    }

    public int getId(){
        return id;
    }

    public void setId(int id){
        this.id = id;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getGrade(){
        return this.grade;
    }

    public void setGrade(Date date){
        Date now = new Date();
        long HM = (long)now.getTime() - (long)date.getTime();
        HM = (long)(HM/(1000*60*60*24));
        this.grade = Grade_user(HM);
    }

    public String Grade_user(long HM){
        if(HM<30){
            return "新人";
        }else if(HM<=100){
            return "星星";
        }else if(HM<=365){
            return "月亮";
        }else if(HM<=365*2){
            return "大月亮";
        }else {
            return "太阳";
        }
    }

    private int time;

    public int getTime(){
        return this.time;
    }

    public void setTime(Date date){
        Date now = new Date();
        long HM = (long)now.getTime() - (long)date.getTime();
        HM = (long)(HM/(1000*60*60*24));
        this.time = (int)HM;
    }

}
